﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for NhatDatBaiDangManager
/// </summary>
public class NhatDatBaiDangManager
{
    NhatDatBaiDangDAO baiDangDAO;
	public NhatDatBaiDangManager()
	{
        baiDangDAO = new NhatDatBaiDangDAO();
	}

    public List<NhaDatBaiDang> GetAllNhaDatIndex(int rowCount)
    {
        List<NhaDatBaiDang> result = new List<NhaDatBaiDang>();

        DataTable dt = baiDangDAO.GetDataLimit(rowCount);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            NhaDatBaiDang nd = new NhaDatBaiDang();
            nd.ID = Convert.ToString(dt.Rows[i]["ID"]);
            nd.TieuDe = Convert.ToString(dt.Rows[i]["TieuDe"]);
            nd.Tinh = Convert.ToString(dt.Rows[i]["Tinh"]);
            nd.Gia = Convert.ToString(dt.Rows[i]["Gia"]);
            DonViNhaDat loaiTien = new DonViNhaDat();
            loaiTien.ID = Convert.ToString(dt.Rows[i]["ID"]);
            loaiTien.Ten = Convert.ToString(dt.Rows[i]["Ten"]);
            nd.DonVi = loaiTien;
            nd.DiaChi = Convert.ToString(dt.Rows[i]["DiaChi"]);
            nd.DienTich = Convert.ToString(dt.Rows[i]["DienTich"]);
            nd.HuongNha = Convert.ToString(dt.Rows[i]["Huong"]);

            result.Add(nd);
        }

        return result;
    }

}